package com.jxs.test;

import java.util.Scanner;

public class atm_one {
	static Scanner sc = new Scanner(System.in);
	static ATM t = new ATM();
	static int butt;
	static double cMonety;
	static double qMonery;
	static String yMonery[] = new String[50];
	public static void main(String[] args) {
		login();
	}
	public static void button() {
		do {
			System.out.println("1.存款");
			System.out.println("2.取款");
			System.out.println("3.查看余额");
			System.out.println("4.交易信息");
			System.out.println("退出");
			System.out.println("请选择你要执行的操作");
			butt = sc.nextInt();
			while (butt != 1 && butt != 2 && butt != 3 && butt != 4 && butt != 5) {
				System.out.println("没用找到该服务，请重新输入");
				butt = sc.nextInt();
			}
			switch (butt) {
			case 1:
			case1();
				break;
			case 2:
				case2();
				break;
			case 3:
				case3();
				break;
			case 4:
				case4();
				break;
			}
		} while (butt != 5);
		System.out.println("退出系统");
	}
	static void login() {
		t.ures = "123456";
		t.pwd = "000000";
		t.money = 500d;
		String uresname;
		String mypwd;
		for (int i = 2; i >= 0; i--) {
			System.out.println("请输入用户名");
			uresname = sc.next();
			System.out.println("请输入密码");
			mypwd = sc.next();
			if (!t.ures.equals(uresname) || !t.pwd.equals(mypwd)) {
				if (i == 0) {
					System.out.println("卡已冻结");
					break;
				}
				System.out.println("还有" + i + "次机会");
			} else {
				System.out.println("登陆成功");
				button();
				break;
			}
		}
	}
	static void case1() {
		System.out.print("请输入存款金额");
		cMonety = sc.nextDouble();
		if (cMonety > 1000) {
			System.out.println("单次存款金额不能大于1000");
		} else if (cMonety < 0) {
			System.out.println("不能存负数的钱");
		} else if (cMonety % 100 != 0) {
			System.out.println("不能存零钱");
		} else {
			t.money += cMonety;
			System.out.println("存款成功");
			for (int i = 0; i < yMonery.length; i++) {
				if (yMonery[i] == null) {
					yMonery[i] = "存款" + cMonety;
					break;
				}
			}
		}
	}
	static void case2() {
		System.out.println("请输入取款金额");
		qMonery = sc.nextDouble();
		for (int i = 0; i < yMonery.length; i++) {
			if (yMonery[i] == null) {
				yMonery[i] = "取款" + qMonery;
				break;
			}
		}
		t.money -= qMonery;
		if (qMonery > 1000) {
			System.out.println("单次取款金额不能大于1000");
		} else if (qMonery < 0) {
			System.out.println("不能取负数的钱");
		} else if (qMonery % 100 != 0) {
			System.out.println("不能取零钱");
		} else if (qMonery > t.money) {
			System.out.println("你没有那么多钱");
		} else {
			System.out.println("取款成功");
		}
	}
	static void case3() {
		if (t.money < 1000_0) {
			System.out.println("显示余额为" + t.money + "你真是个穷逼");
		} else if (t.money > 1000_0) {
			System.out.println("显示余额为" + t.money);
		}
	}
	static void case4() {
		System.out.println("交易信息");
		for (int i = 0; i < yMonery.length; i++) {
			if (yMonery[i] != null) {
				System.out.println(yMonery[i]);
			}
		}
	}
}
